<!DOCTYPE html>
<html lang="zh-cn">
<head>
<title>{$title}</title>
<meta name="renderer" content="webkit">
<meta http-equiv="x-ua-compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<meta content="no-cache, no-store, must-revalidate" http-equiv="Cache-Control" />
<meta content="no-cache" http-equiv="Pragma" />
<meta content="0" http-equiv="Expires" />
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<link rel="stylesheet" href="/static/css/zui.min.css" />
</head>
<body>

<script type="text/javascript" src="{$_lang.company_path}/admin/template/js/jquery.min.js"></script>
<script type="text/javascript" src="/static/js/zui.js"></script>
<script type="text/javascript" src="{$_lang.company_path}/admin/template/js/common.js"></script>

<style type="text/css">
/*新闻详情页*/
.new-detail{
	max-width:640px;
	margin:0 auto;
}
.new-detail>i{
    font-size: 24px;
    color: #13a09e;
    position: fixed;
	z-index:10;
    top: 20px;
    left: 20px;
}
.new-detail>.new-content{
	padding:10px;
}
.new-detail>.new-content>img{
    max-width:100%;
}
.new-detail .new-title{
	position:fixed;
	top:0;
	left:0;
	background:#fff;
	width:100%;
    height:60px;
	font-size:16px;
	line-height:65px;
	overflow:hidden;
	text-align:center;
	padding:0 10px 0 40px;
	border-bottom:1px solid #eee
}
/*返回按钮*/
.back-fg{
    position: fixed;
    z-index: 20;
    bottom: 0;
    left: 0;
    height: 60px;
    width: 100%;
    background: rgba(255,255,255,0.5);
}
.back-go{
    display: inline-block;
    position: fixed;
    z-index: 30;
    bottom: 10px;
    left: 30%;
    height:40px;
    text-align: center;
    line-height: 40px;
    font-size: 16px;
    width: 40%;
    background: #2db2b0;
    color: #ffffff;
    border-radius: 4px;
    border: 2px solid #13a09e;
}
/*评论表单*/
form.article_comment{
	padding:10px;
	border-top: 1px solid #ddd;
    border-bottom: 1px solid #ddd;
    background: #eee;
}
form.article_comment input[type=text],form.article_comment textarea{
	border:1px solid #555;padding:4px;border-radius:4px;
}
/* 留言 */
#comment{
	padding:10px;
}
#loading{
	padding:10px;text-align:center;display:none;
}
.news_pub_time{
	height:40px;line-height:40px;padding:0 10px;font-size:14px;background:#eee;border-bottom:1px solid #ddd;
}
</style>

{if $act eq "lists"}
	<!--新闻列表 begin-->
	<div class="new-detail">
		{if !empty($news[0]['pic'])}<img src="{$news[0]['pic']}" style="max-width:100%;max-height:200p;x" />{/if}
		<div id="list_articles">
		</div>
		<div id="loading"><img src="/static/images/s_loading.gif"/></div>
	</div>
	<script>
		var page = 1;
		var cat_type = '{$cat_type}';
		$(function(){
			list_articles();
			$('.new-detail').scroll(function(){
				var scrollTop = $(this).scrollTop();
				var divHeight = $(this).height();
				var scrollHeight = $(this)[0].scrollHeight;
				if(scrollTop + divHeight +30>= scrollHeight){
					list_articles();
				}
			});
		});
		var flag = true;
		var flag_one = true;
		function list_articles(){
			if(flag && flag_one){
				flag_one = false;
				$("#loading").show();
				//alert_notice("加载中...",'success','bottom',500);
				$.post('/news/?act=ajaxNewsList',{
					'cat_type':cat_type,
					'page':page
				},function(res){
					flag_one = true;
					console.log(res);
					if (res.length==0) {
						flag = false;
						//alert_notice("没有更多了",'default','bottom');
					}
					else{
						page++;
						var html = "";
						for(var i=0;i<res.length;i++){
							var data = res[i];
							html += '<a style="text-decoration:none" href="/news/?nid='+data.id+'">'
								 + '<div style="padding:10px;color:#333;border-bottom:1px solid #eee">'
								 +	'<div style="font-size:16px">'+data.title+'</div>'
								 +	'<div style="font-size:13px">'+data.create_time+'</div>'
								 + '</div>'
								 + '</a>';
						}
						$("#loading").hide();
						$("#list_articles").append(html);
					}
				},'json');
			}
		}
	</script>
{else}
	<!--新闻详情页 begin-->
	<div class="new-detail">
		<i class="icon icon-angle-left" onClick="javascript:window.location.href='{$back_url}'"></i>
		<div class="new-title">{$news.title}</div>
		<div style="height:60px"></div>
		<div class="news_pub_time"><i class="icon icon-time"></i> {$news.create_time}</div>
		<div class="new-content">
            {$news.content}	
		</div>
		{foreach $childNews as $k => $val}
				<div class="news_pub_time"><i class="icon icon-time"></i> {$val.create_time}</div>
				<div class="new-content">{$val.content}</div>
			
		{/foreach}
		
		<script type="text/javascript" src="/static/js/jquery.form.js"></script>
		<script type="text/javascript" src="{$_lang.company_path}/admin/template/js/jquery.form.submit.js"></script>
		<form action="/comment/?act=comment" id="form" method="post" enctype="multipart/form-data" class="article_comment">
			<p><input type="text" name="name" placeholder="请输入您的姓名">
			<p><input type="text" name="phone" placeholder="请输入您的手机号">
			<p><textarea name="comment" id="" cols="30" rows="5" placeholder="请输入您的留言内容"></textarea>
			<input type="hidden" name="nid" value="{$nid}">
			<input type="hidden" name="c_id" value="{$news.c_id}">
			<div>
			<input type="button" class="btn btn-primary" value="确认提交" id="sub_btn" onClick="javascript:ajaxFormSubmit('form','提交');">			
			<span id="wrong_text"></span>
			</div>
			<div style="clear:both"></div>
		</form>
		
		<div id="comment">		
 		</div>
		
	</div>
	<script>
        var page = 1;
        var nid = '{$nid}';
        $(function(){
            list_comments();
            $('.new-content').scroll(function(){
                var scrollTop = $(this).scrollTop();
                var divHeight = $(this).height();
                var scrollHeight = $(this)[0].scrollHeight;
                if(scrollTop + divHeight +30>= scrollHeight){
                    list_comments();
                }
            });
        });
		var flag = true;
		var flag_one = true;
        function list_comments(){
            if(flag && flag_one){
                flag_one = false;
                $.post('/comment/?act=ajaxComment',{
                    'nid':nid,
                    'page':page
                },function(res){
                    flag_one = true;
                    if (res.length==0) {
                        flag = false;
                    }
					else{
                        page++;
                        var html = "";
                        for(var i=0;i<res.length;i++){
                            var data = res[i];
							
							
							html += '<div '+(i==0 ? '' : 'style="margin-top:10px;"')+'>' 
							         + '<font style="color:#1970fc">'+data.name+'</font> 留言于 '+data.createtime+'<br>'
							         + data.comment
							         + '</div>';
                            for(var j=0;j<data.child.length;j++){
                                var data_child = data.child[j];
                                html += '<div style="margin-left:10px;background:#eee;border:1px solid #ddd;padding:5px">'
									 +'【'+data_child.name+'】 回复于 '+data_child.createtime+'<br>'
									 + data_child.comment
									 +'</div>';
                            }
                            /*
							if(data.chuli_yijian !== ""){
                                html += '<div class="comment_chuli_yijian">' +
                                    '<div>处理意见:</div>' +
                                    '<div class="comment_chuli_yijian_context">'+data.chuli_yijian+'</div>' +
                                    '</div>';
                            }
							*/
						}
						$("#comment").append(html);
                    }
                },'json');
			}
        }
	</script>
{/if}

<div style="height:50px"></div>
<div class="back-fg">
	<button  onClick="javascript:window.location.href='/company/?cid={$c_id}';" class="back-go">返回商户</button>
</div>

</body>
</html>